
import LogService from "../service/LogService";


export default class WXUtils {
  static setBarTitle(title){
    uni.setNavigationBarTitle({
      title,
    })
  }

  /**
   * screenHeight: 667
      screenWidth: 375
   * @returns {Promise<void>}
   */
  static async getWindowsSize(){
    let res = await uni.getSystemInfo();
    LogService.debug("getBarHeight", res);
    const {statusBarHeight, screenWidth, screenHeight} = res;
    return {statusBarHeight, screenWidth, screenHeight};
  }

  /**
   * promise 形式  login
   */
  static login() {
    return new Promise((resolve, reject) => {
      uni.login({
        provider: 'weixin',
        success: (result) => {
          resolve(result);
        },
        fail: (err) => {
          reject(err);
        }
      });
    })
  }
}
